Data Conversion
The Data Conversion facility allows you to change the values held in a Data Source or Custom View column to something different when displayed within your app, usually to something more meaningful to the user, or to provide a visual guide to the data's content.
For example, you could have a list of jobs, each with a status value indicating its progress, such as 0 for "Not started", 1 for "Started", 2 for "Awaiting Parts" etc. The Data Conversion facility could be used to display the status values as meaningful text, "Not Started", "Started" etc., rather than the 0, 1 ... etc. stored in the actual database, so that your users don't have to know the code values. You can also convert data values into images, allowing you, for example, to include a visual representation of the job status giving users an at-a-glance view of the status of each job. In addition, you can apply a Style to each input value allowing you to change the font, change the colour of the text or background and/or embolden or italicise text to readily highlight the job's status, such as displaying a red background for urgent jobs and a green background for completed jobs based on the status value in each record.
Data Conversion can also be used to reverse these changes, so that the values displayed on the form are converted back to the required values for the database when data from the form is written to the current record.
The feature allows you to create a set of Conversion Tables which define your conversions which you can then allocate to a Control within your app. The Conversion Tables are not specific to a Data Source, Custom View or column within a data table nor to a Control; rather, they simply provide a list of values to be read or written and the corresponding display values or images and any Style you want to be applied. This means that you could use the same Conversion Table for different data if applicable. For example, if you had two Data Sources both using the same Status data values, you could use the same Conversion Table to convert both to the same consistent set of pictures.
You can also use the same Conversion Table for both input and output data conversions, for example where Controls have input and output mappings to the same data table. An Input Data Conversion will be applied to data being read from a record in a local database table to a Control and an Output Data Conversion will be applied to data being written from a Control to a record in a local database table.
You can perform Input Data Conversions for most Controls providing the data assigned to the Control is alpha-numeric.
Output Data Conversions are only available for Edit Controls, HTML Text Controls, Combo Boxes, List Boxes and Static Controls.
Data Conversion Tables are assigned to a Control using its Input Conversion or Output Conversion Properties. Assigning a Conversion Table to a Control's Input Conversion Property will act upon data being read from a local database column into the Control, converting the values read in according to the specification in the Conversion Table and displaying the converted values in the Control instead of those stored in the actual database. Assigning a Conversion Table to its Output Conversion Property will act upon data being read from the Control and written to a local database table, converting the displayed values into the required values for storage in the database table.
Conversion Tables are created, viewed and edited using the Data Conversions dialog box which is also accessed from the Input Conversion or Output Conversion Properties of a Control (see below). When you create a new Conversion Table it will automatically be applied to the Property from which you create it. An existing Table can be applied manually to either or both Properties for a Control.
Firstly, if you want to convert input data to pictures, you will need to add the required images into your Project in the normal way, if they haven't already been imported. The easiest way to do this is to display the Resources Pane and then drag the required images onto it from Windows Explorer.
We recommend that, if possible, you create your images at the same size as the control they will be displayed in, making your app less processor-intensive when scaling the images to fit the control. Note, however, if you are developing a Digitise app for Android devices you may need to scale the image depending upon the screen resolution(s) of your intended device(s).
Secondly, if you want to assign different Styles to the Control based on the input data values, you will need to create any Styles you want to use, which don't already exist, before you create or edit your Conversion Table.
For example, you could use Styles to indicate the status of items listed in a ListView by the use of colour, such as by displaying a coloured square at the beginning of each row or by changing the background colour of the row depending upon the value in a specified data column as shown in the following pictures:
In the first picture, the coloured square is made from a Static Control input mapped to the data's status column. A Data Conversion Table then changes the style assigned to the Static Control based on the value in the status column. In each case, the style used has both the foreground and background colours set to the same colour so the data value itself can't be seen.
In the second picture, the coloured background is made by adding a Static Control to the ListView Template and resizing it so that it fills the width & height of the Template's Panel. This Control is then input mapped to the data's status column. Next, you can place the Controls which will display the data on top of the full width background Control. Finally, the background Control is linked to a Data Conversion Table which, once again, assigns a style based on the value in the status column. As in the first example, the styles used have both foreground and background colours set to the same colour.
If you are converting alpha-numeric data to other alpha-numeric data, you do not need to do anything before creating or editing a Data Conversion Table.
When you are ready, display the relevant form or Template and then select the required Control to display its Properties in the Properties Pane.
- If you want to convert input values to images, you will need to use a Picture & Video Control on the form or Template, even though the original data will be numeric or character based.
To create a conversion table, locate and click on the Input Conversion or Output Conversion Property depending upon whether you want to create an input or output conversion table.
Note that the Properties can be found under the Target category which means that you can specify different Conversion Tables for different Platforms and screen resolutions if required.
Creating a Conversion Table from the Input Conversion Property allows you to specify both string to string and string to picture conversions and allows you to assign Styles to the input data values.
Creating it from the Output Conversion Property only allows string to string conversions to be defined. Styles are not relevant to Output Conversions.
- The only difference between creating a Conversion Table from the Input Conversion Property as opposed to from the Output Conversion Property is the type of conversions you can specify within the Table. Once a Table has been created it can be applied to either or both Properties as appropriate.
- Remember, however, that Tables converting strings to Pictures can only be opened, created and edited from and assigned to an Input Conversion Property and if you close the dialog box used to create, view and edit Conversion Tables using its OK button, the Conversion Table currently displayed within the dialog will automatically be assigned to the Property from which the dialog box was opened.
- Style conversions only apply to input conversions and if you assign a Conversion Table which has style conversions to the Output Conversion Property of a Control, the style settings will be ignored.
When you click on one of the Conversion Properties, a drop-down arrow, , and a browse button, , will be displayed at the right-hand edge of the Property's value.
To create, view or edit a Data Conversion Table, choose .
The Data Conversions dialog box will be displayed:
The picture above shows the Input Data Conversions dialog but the Output Data Conversions dialog is basically the same.
To view or edit an existing Conversion Table, select the required Table from the Conversion Tables drop-down at the top of the dialog box. The current values in the selected Table will be displayed in the dialog. You can edit any of the data in the same was as described below for creating a new Table.
To start a new Conversion Table, choose the New button.
A dialog box will appear asking you to enter a name for this Table. Type in a name and choose OK.
The name will be displayed in the Conversion Tables field at the top of the dialog box.
You now need to select the type of conversion you want to be performed.
If you are creating an Input Conversion Table, you can convert incoming alpha-numeric data to other alpha-numeric data or to pictures. To convert alpha-numeric data to alpha-numeric strings select Alpha Numeric in the Mode option. Alternatively, if you want to convert alpha-numeric data to pictures, select Picture. Note that Style conversion is only supported with Alpha Numeric conversion tables and not with Picture conversion tables. Note also that when converting strings to pictures, you can only use pictures; you cannot not convert to videos.
If you are creating an Output Conversion Table, you can only convert displayed alpha-numeric data to other alpha-numeric data, you cannot convert images to strings. The Mode option will automatically be set to Alpha Numeric.
You can now specify the conversions you want to perform.
The Conversion section of the dialog box allows you to specify an individual conversion. The Data Value field allows you to enter the value as it will appear in the data record and the Control Value field allows you to specify the corresponding value as it will appear in the Control. The Style field allows you to assign a Style to be used by the Control when the specified Data Value is read in.
For Input Conversions, the Data Values define the possible values which could be downloaded from the remote Data Source and the Control Values define the string or image you want to display in your app in place of each possible input value. The Styles specify the Styles to be applied to the Control for each of the possible Data Values.
For Output Conversions, the Control Values define the strings that could be displayed in your app and the Data Values define the values which will be written to the Data Source in place of each possible displayed value.
For each set of values, you enter the relevant information in the Conversion section of the dialog box and then add it to the conversion table below.
If you are in Alpha Numeric Mode and specifying an Input Conversion, enter the first number or text string that you want to be converted in Data Value and then the value you want to be displayed in place of the Data Value in Control Value. If you want to apply a Style to this Data Value, select the required one from the Style drop-down.
For example, suppose your input data for this Control is a numerical Status value, and you want to convert non-intuitive numbers into explanatory text. So, in this instance you might enter 0 as the Data Value and then something like Not Started as the Control Value. Now when your users run your app, when a status value of 0 is received from the remote Data Source, this Control will automatically display 'Not Started' instead of 0. In this situation, you might decide to display the text in red to highlight it to the user, so you would select the Style you created for this purpose in the Style field.
Note that the Data Value doesn't have to be numeric, you can equally convert text strings to other text strings if required, e.g. the Status value might be 'Not Started' but you might want to abbreviate it to 'NS' or change it to something completely different such as 'Awaiting Scheduling'.
Note also that you don't have to specify a Control Value if you are specifying a Style. For example, in the earlier pictures showing a change of colour based on the value in the status column, you wouldn't need to specify a Control Value since, in these cases, the value will be hidden from the user and so it doesn't matter what that value actually is.
- If you only want to specify style changes and you don't want to change the data values as well, set the Inbound option, in the Defaults section at the bottom of the dialog box, to Pass Through, if you want the original input mapping values to be displayed.
If you are in Alpha Numeric Mode and specifying an Output Conversion, enter the value that will be displayed in the Control in the Control Value field and then the value you want it to be converted to when written to a data record in the Data Value field. Using a similar example to the previous one, you might enter 'Not Started' in the Control Value field and 0 in the Data Value field. Now when the Control is used to update the current record, if the user has selected 'Not Started' in the Control, the data record would be updated with 0.
Remember, the same Alpha Numeric Conversion Table can work both ways to convert input and output data for the Control, where the Output Conversion is the reverse of the Input Conversion.
For this reason, when creating an Output Conversion Table, you can specify a Style in the Style field, even though the Style will be ignored when the table is assigned to an Output Conversion because it will take effect if the same Table is assigned to an Input Conversion.
If you are defining an Input Conversion Table and you have selected Picture Mode, again you enter the value to be converted in the Data Value field. Now, however, the Control Value field contains a drop-down list of images available within the Project from which you can choose the one you want to be displayed when the specified Data Value is input into this Control.
So, in our example above, instead of converting '0' to 'Not Started', you could have a set of images to depict the status visually and convert '0' to the relevant image within the set. If you were displaying this data within a ListView Control you could use this feature to provide a visual indication of the status of each item in the list by adding a picture to, say, the start or end of each row in the list.
Don't select a Style in the Style field since Style conversion is only supported with Alpha Numeric conversion tables and not with Picture conversion tables.
When you have entered the details for this conversion, choose the Add button to add the conversion to the Table.
You can now enter the details of the other conversions and then add them to the Table in the same way.
In addition to specifying specific conversions you can also enter a default conversion which will be used for any value which isn't specifically listed in the Conversion Table. Alternatively, you can specify that any such value should be passed through to the Control or the data record without any conversion being performed. You can specify separate defaults for Input and Output Conversions.
To specify a default conversion, click on the down arrow symbol at the end of the appropriate drop-down list in the Defaults section of the dialog below the Conversion Table. Use the Inbound option to specify a default value for Input Conversions and the Outbound option for Output Conversions.
For Input Conversions choose This Value to specify a particular value to be displayed in the Control. The field to the right will be labelled Control Value or Control Image depending upon whether the Table is in Alpha Numeric or Picture Mode, respectively. In this field, either enter the value you want to be displayed or select the image to be displayed as appropriate. If you want the undefined value to be displayed in the Control and not converted, choose Pass Through instead.
- For an Alpha Numeric Input Conversion, if you only want to specify style changes and you don't want to change the data values as well, set the Inbound option here to Pass Through, if you want the original input mapping values to be displayed.
- There is no default style option to cover the Style to be assigned to any data values which haven't been specifically included. If a value is read in which isn't in the conversion list, the Control will use the Style specified in its own Style Property.
For Output Conversions, drop down the list in the Outbound option and choose This Value if you want any undefined value displayed in the Control to be converted to a specific value when written to a data record or Pass Through if you want it to be written to the record without being converted. If you choose This Value, specify the value you want to be written to the data record in the Data Value field to the right.
If you want to edit an existing conversion, select the row within the Conversion Table. The values will appear in the fields above the table and you can change them. When you are happy, click on the Update button to update the Table.
You can also delete a conversion by selecting the relevant row within the table and then choosing the Delete button below the table, or you can clear the whole Table by choosing the Delete All button.
The values you enter in the Conversion Table are saved as you go along, which means you can display and edit any of the other Conversion tables whilst in the Data Conversions dialog box. Simply select the required Table in the Conversion Tables field at the top of the dialog box. You can also delete an existing Conversion Table by selecting it at the top of the dialog box and then choosing the Delete button to the right of the table name.
When you have finished in the dialog box, either choose the OK button to assign the currently selected Conversion Table to the Property you loaded the dialog from and return to your form or Template or click on the Close button in the top right-hand corner of the dialog box, , to close the dialog without assigning the Conversion Table to the Property. In either case, any changes you made in the dialog box will automatically be saved.
Once you have created a Conversion Table, you can assign it to any Control or Controls as appropriate.
To do this:
Select the relevant Control on your form or Template to display its Properties in the Properties Pane.
If you want to assign a Conversion Table to input mappings for the Control, locate the Input Conversion Property and click on it to display the drop-down arrow, , at the end of the row. Click on the arrow and choose the required Conversion Table from the list of Tables displayed. Alternatively, to remove Data Conversion from this Control choose <none>.
If you want to assign a Conversion Table to output mappings for the Control, locate the Output Conversion Property instead and click on it to display drop-down arrow, , at the end of the row. Click on the arrow and choose the required Conversion Table from the list of Tables displayed. Note that only Alpha Numeric tables will be included in the list for an output mapping. Alternatively, to remove Data Conversion from this Control choose <none>.
- The changes you make in the Data Conversions dialog box are saved within App Studio as you go along, but you will still need to save your Project in order to save the changes within the Project. If you do not save your Project, the next time you load it your changes will have disappeared. We recommend that you save the Project from time to time as you are working and when you publish a Project, it is automatically saved, if necessary, before being published.